//
//  ST_EngagementRuleTipsViewController.swift
//  btvideo
//
//  Created by mac on 2020/12/9.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyAttributes
import SwiftyUserDefaults

//MARK: -

class ST_EngagementFemaleTipsViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor  = .clear
        
        view.addSubview(cover_image_view)
        cover_image_view.snp.makeConstraints { (make) in
            make.width.equalTo(300)
            make.height.equalTo(372)
            make.center.equalToSuperview()
        }
        
        view.addSubview(confirm_btn)
        confirm_btn.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.width.equalTo(232)
            make.height.equalTo(44)
            make.bottom.equalTo(cover_image_view).offset(-20)
        }
        
        
    }
    
    fileprivate lazy var cover_image_view:UIImageView = {
        
        let control = UIImageView()
        
        control.contentMode = .scaleAspectFill
        
        control.pin_setImage(from: SCComponets.rich_text_storage_component.json["flash_item0"]["flashRul_url"].url)
        
        return control
    }()
    
    fileprivate lazy var confirm_btn:UIButton = {
        
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.backgroundColor = UIColor.init(hexString: "#FEC207")
        control.cornerRadius = 44/2.0
        control.setTitleForAllStates("我知道啦")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
        control.setTitleColorForAllStates(UIColor.white)
        control.addTarget(self, action: #selector(confirm_handle), for: UIControl.Event.touchUpInside)
        return control
    }()
    
    var confirm_closure:(()->())?
    
    @objc fileprivate func confirm_handle(){
        
//        self.dismiss(animated: false, completion: nil)
        
        self.dismiss(animated: false) {
            self.confirm_closure?()
        }
        
    }
    
}


//MARK: - Tips View
class ST_EngagementMaleRuleView: UIControl {
    
    static let height = 110
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.top.centerX.equalToSuperview()
            make.width.height.equalTo(24)
        }
        
        self.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(icon_image_view.snp.bottom).offset(10)
            make.height.equalTo(70)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate lazy var icon_image_view:UIImageView = {
        let control = UIImageView.init(image: ST_ImageUtils.imageName("engagement_report_icon"))
              return control
          }()
    
    
    fileprivate lazy var content_label:UILabel = {
        let control = UILabel.init()
        control.numberOfLines = 0
        let p = NSParagraphStyle.create_line_spacing_paragraph_style(lineSpacing: 5)
        p.alignment = .center
        control.attributedText = "通话过程中禁止侮辱、谩骂他人等违规行为；\n严禁出现涉嫌违法的言论和内容；\n一经发现，从严处理！".withAttributes([Attribute.textColor(.white),.font(Font.systemFont(ofSize: 14, weight: UIFont.Weight.medium)),.paragraphStyle(p)])
        return control
    }()
}
